package com.yxy.controller.user;

import com.yxy.common.PageResult;
import com.yxy.common.Result;
import com.yxy.constant.RequestMapperConstant;
import com.yxy.pojo.dto.SightsPageQueryDTO;
import com.yxy.pojo.entity.Sights;
import com.yxy.pojo.vo.SightsVo;
import com.yxy.service.SightsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("userSightsController")
@RequestMapping(RequestMapperConstant.USER_REQUEST_MAPPER + "sights")
@Slf4j
public class SightsController {

    @Autowired
    private SightsService sightsService;

    /**
     * 分页查询
     * @return
     */
    @GetMapping("/page")
    public Result<PageResult> page(SightsPageQueryDTO sightsPageQueryDTO){
        log.info("分页查询景点信息：{}", sightsPageQueryDTO);
        PageResult result = sightsService.pageQueryEnable(sightsPageQueryDTO);
        return Result.success("", result);
    }

    /**
     * 增加景点浏览量
     * @param id
     * @return
     */
    @PutMapping("/addViews/{id}")
    public Result addViews(@PathVariable Integer id){
        log.info("增加景点浏览量：{}", id);
        sightsService.addViews(id);
        return Result.success("", null);
    }

    /**
     * 查询景点详情
     * @param id
     * @return
     */
    @GetMapping("/getSightsDetail")
    public Result<SightsVo> getSightsDetail(Integer id){
        log.info("查询景点详情：{}", id);
        SightsVo vo = sightsService.getSightsDetail(id);
        return Result.success("", vo);
    }
}
